#include "Util.h"
#include <vector>
#include <list>
#include <hash_map>
#include <boost\functional\hash.hpp>
#include <algorithm>
namespace Core
{
	namespace GameLogic
	{
		class Element;
		
		class Less
		{
		public:
			bool operator()(const Position& p1,const Position& p2) const
			{
				return p1.x<p2.x || p1.x==p2.x && p1.y<p2.y;
			}
		};

		class my_hash_comp:public stdext::hash_compare<Position,Less>
		{
		public:
			size_t operator()(const Position& p) const
			{
				return boost::hash_value(std::make_pair(p.x,p.y));
			}
			bool operator()(const Position& _Keyval1, const Position& _Keyval2) const
			{	// test if _Keyval1 ordered before _Keyval2
				return (comp(_Keyval1, _Keyval2));
			}
		};
		

		
		//Manage the elements added in the map
		//Query elements thought position.
		//Manage the collision ..not implemented
		class ElementManager
		{
		public:
			ElementManager(const Size& mapSize);
			void AddElement(Element* element);
			void RemoveElement(Element* element);

			list<Element*> GetElement(const Position& position);
		private:
			const Size& m_mapSize;
			
			int width,height;
			stdext::hash_multimap<Position,Element*, my_hash_comp > blocks;
		};

	
	}
}